/*------------------
This Widget Has Be Made By Fadz:HantuJavascript.blogspot.com...
Supported By PrayTimes.org...
this widget is really Hard to make...
so please do not change anything...

Dalam Script ini banyak perkataan */var// yang akan di jumpai
/*dan sukar sekiranya anda memadamya...ia akan menggangu perjalana script ini..
dan sekiranya berlaku anda perlu merujuk */hantujavascript=true;//.........
/*dan jangan padam mesej ini
------------------*/
var STTPS=new Date("21 July 2012 00:00 AM");
var ENDPS=new Date("19 August 2012 00:00 AM");
function SWBP2PO(S1,S2,S3,A,B,C,D,E,F,G,H,I,J,K,M,N){
	var GAR=document.getElementById("BerbukaMain"+D);
	var L='\n-wibkit-border-radius:'+E+'px;\n-moz-border-radius:'+E+'px;\n-o-border-radius:'+E+'px;\nborder-radius:'+E+'px;';
	var GG=new Date();
	if(GG>ENDPS||(!S1&&!S2&!S3)){
		allowSoundPuasa.adhan= false;
		allowSoundPuasa.sahur[0]= false;
		S1=false;
		S2=false;
		S3=false;
		GAR.innerHTML='<img src="'+KadRaya+'" style="-wibkit-border-radius:'+(E+10)+'px;-moz-border-radius:'+(E+10)+'px;-o-border-radius:'+(E+10)+'px;border-radius:'+(E+10)+'px;" width="'+(J)+'" height="'+((J)*(100/150))+'"/><br/><div id="theFastingMessage">'+msjRaya+'</div>';
		callbackHriRaya();
	}else{
	GAR.innerHTML='<style>\n#BerbukaMain'+D+' {\nbehavior: url(http://js-and-all.googlecode.com/svn/trunk/ie-css3.htc);font-size:'+K+'px;'+L+'\nborder:'+F+';\n width:'+J+'px;\npadding:'+G+'px;\n}\n#BerbukaMain'+D+' table {\ntext-align:center;'+L+'\nborder:'+F+';\npadding:'+H+'px;\nmargin-bottom:3px;\n}\n#BerbukaMain'+D+' table td {'+L+'\nborder:'+F+';\n}\n#myTimeWrite'+D+' {'+L+'\nborder:'+F+';\n}\n#innerMainImg'+D+' {'+L+'\nborder:'+F+';\npadding:'+I+'px;\nmargin-bottom:3px;\n}\n</style>';
	
	if(S1){GAR.innerHTML+='\n<div id="innerMainImg'+D+'">\n<img id="thumbImg'+D+'" width="'+(J-E-I-G-10)+'" height="'+((J-E-I-G-10)*(100/150))+'" style="-wibkit-border-radius:'+E+'px;-moz-border-radius:'+E+'px;-o-border-radius:'+E+'px;border-radius:'+E+'px;"/>\n<div id="outFastingBar'+D+'" style="-wibkit-border-radius:5px;-moz-border-radius:5px;-o-border-radius:5px;border-radius:5px;background:'+M+';height:7px;width:'+(J-E-I-G-I-G)+'px;text-align:right;">\n<div id="inFastingBar'+D+'" style="-wibkit-border-radius:5px;-moz-border-radius:5px;-o-border-radius:5px;border-radius:5px;background:'+N+';height:7px;width:'+(J-E-I-G-I-G)+'px;"></div></div>\n<div id="theFastingMessage'+D+'"></div>\n</div>';}
	
	if(S2){GAR.innerHTML+='\n<table style="width:100%;">\n<tr>\n<td colspan="2" style="word-wrap:break-word">'+msjWaktuSmasa+'</td>\n</tr>\n<tr>\n<td id="sahurMsg'+D+'" style="word-wrap:break-word"></td>\n<td id="berbukaMsg'+D+'" style="word-wrap:break-word"></td>\n</tr><tr>\n<td id="sahurTime'+D+'"></td>\n<td id="berbukaTime'+D+'"></td>\n</tr>\n</table>';}
	
	if(S3){GAR.innerHTML+='\n<div id="myTimeWrite'+D+'"></div>';}
	}
	document.getElementById('igetIt'+D).style.width=J+"px";
	checkImsakMaghrib(S1,S2,S3,A,B,C,D);
	setInterval("checkImsakMaghrib("+S1+","+S2+","+S3+","+(A)+","+(B)+","+(C)+","+(D)+");", 500);
}
function checkImsakMaghrib(S1,S2,S3,N,E,Z,ID){
if(hantujavascript){
if(S2){
	function GIGI(g){
		var b,tb,s,ts="";
		switch(g){
			case "sb":
				b=fadzXX;
				tb=fadzZZ;
				s="";
				ts="";
			break;
			case "b":
				b=fadzYY;
				tb=fadzZZ;
				s="";
				ts="";
			break;
			case "s":
				s=fadzYY;
				ts=fadzZZ;
				b="";
				tb="";
			break;
			default:
				b="";
				tb="";
				s="";
				ts="";
		}
		SMSJ.style.background=s;
		SMSJ.style.color=ts;
		STSJ.style.background=s;
		STSJ.style.color=ts;
		BMSJ.style.background=b;
		BMSJ.style.color=tb;
		BBTM.style.background=b;
		BBTM.style.color=tb;
	}
}
function getById(x){
	return document.getElementById(x);
}
if(N&&E&&Z){
	var GG = new Date();
	var theOuterBar = getById("outFastingBar"+ID), theInnerBar = getById("inFastingBar"+ID), myTimeWrite = getById("myTimeWrite"+ID), STSJ = getById("sahur"+"Time"+ID), SMSJ = getById("sahurMsg"+ID), BBTM = getById("berbukaTime"+ID), BMSJ = getById("berbukaMsg"+ID), vthumbImg = getById("thumbImg"+ID), fstingmsj = getById("theFastingMessage"+ID);
	if(S2){SMSJ.innerHTML=msjSblm;}
	if(S2){BMSJ.innerHTML=msjSlps;}
	var mnth = new Array("January","February","March","April","Mei","Jun","July","August","September","October","November","December"), DD = GG.getDate()+" "+mnth[GG.getMonth()]+" "+((GG.getYear()<2000)?GG.getYear()+1900:GG.getYear());
	var ST = prayTimes.getTimes(GG, [N, E], Z);
	var TS = new Date(DD+" "+ST['imsak']), TZ = new Date(DD+" "+ST['dhuhr']), TA = new Date(DD+" "+ST['asr']), TM = new Date(DD+" "+ST['maghrib']), TI = new Date(DD+" "+ST['isha']), TMN = new Date(DD+" "+ST['midnight']), theZeroTime = new Date(DD+" 0:00 AM");
	var MOTs=ST['maghrib'];
	var subuhOutputTime=ST['imsak'];
	var myAudio = document.createElement("audio"), myAudioSRC;
	var fastingTime = TM-TS;
	var nowfasting = GG-TS;
	var nowbreaking = TM-GG;
	var sunrise,midday,sunset;
	var night,midnight,fajar;
	var timeRemaining,tsdsa;
	MOTs = (parseInt(MOTs.split(":")[0])<12)?(parseInt(MOTs.split(":")[0])%12)+":"+MOTs.split(":")[1]+" AM" : (parseInt(MOTs.split(":")[0])%12)+":"+MOTs.split(":")[1]+" PM";
	subuhOutputTime = (parseInt(subuhOutputTime.split(":")[0])<12)?(parseInt(subuhOutputTime.split(":")[0])%12)+":"+subuhOutputTime.split(":")[1]+" AM" : (parseInt(subuhOutputTime.split(":")[0])%12)+":"+subuhOutputTime.split(":")[1]+" PM";
	TMN=(TMN-0+0);
	GG=(GG-0+0);
	TS=(TS-0+0);
	TZ=(TZ-0+0);
	TA=(TA-0+0);
	TM=(TM-0+0);
	TI=(TI-0+0);
	theZeroTime=(theZeroTime-0+0);
	if(S2){STSJ.innerHTML=subuhOutputTime;}
	if(S2){BBTM.innerHTML=MOTs;}
	sunrise = GG>=TS&&GG<=(new Date(TS+((TZ-TS)/2))-0+0);
	midday = GG>=(new Date(TS+((TZ-TS)/2))-0+0)&&GG<=TA;
	sunset = GG>=TA&&GG<=TM;
	night = GG>=TM&&GG<=TI;
	midnight = (GG>=TI&&GG<=theZeroTime+86400000)||(GG>=theZeroTime&&GG<=TMN);
	fajar = GG>=TMN&&GG<=TS;
	tsdsa = parseInt(GG/1000);
	if(putSahurAlarm&&tsdsa==parseInt(new Date(DD+" "+allowSoundPuasa.sahur[1])/1000)){
		for(var i=0;i<sahurAlarmSource.length;i++){
			myAudioSRC = document.createElement("source");
			myAudioSRC.src=sahurAlarmSource[i];
			myAudio.appendChild(myAudioSRC);
		}
	
		if(allowSoundPuasa.sahur[0]){
			document.body.appendChild(myAudio);
			setTimeout(function(){myAudio.play();}, 5000);
		}
		putSahurAlarm=false;
	}
	if(GG>=TS-1000&&GG<=TM+1000){
		timeRemaining = new Date(theZeroTime+TM-GG);
		timeLapse = new Date(theZeroTime+GG-TS);
		if(S1){theOuterBar.title = "Percent Left:"+parseInt(100-(nowfasting/fastingTime*100))+"\%...\nTime Remaining:"+timeRemaining.getHours()+" Hours,"+timeRemaining.getMinutes()+"Minutes...";
		theInnerBar.title = "Percent Right:"+parseInt(nowfasting/fastingTime*100)+"\%...\nTime Lapse:"+timeLapse.getHours()+"Hours,"+timeLapse.getMinutes()+"Minutes...";
		fstingmsj.innerHTML = msjPuasa;
		theOuterBar.style.background="#f00";
		theInnerBar.style.background="#0f0";
		}
		if(S3){myTimeWrite.innerHTML=DD+"<br/>"+writeIslamicDate()+"<br/>"+new Date(GG).getHours()+":"+new Date(GG).getMinutes();}
		if(sunrise){
			if(tsdsa==TS/1000){changeImg=true;}
			IGS=sunriseImg;
			if(S2){GIGI();}
		}
		if(midday){
			if(tsdsa==(new Date(TS+((TZ-TS)/2))-0+0)/1000){changeImg=true;}
			IGS=middayImg;
			if(S2){GIGI();}
		}
		if(sunset){
			if(tsdsa==TA/1000){changeImg=true;}
			IGS=sunsetImg;
			if(S2){GIGI("sb");}
		}
		if(putTheAdhanAudio&&tsdsa==parseInt(TM/1000)){
			for(var i=0;i<adhanAudioSource.length;i++){
				myAudioSRC = document.createElement("source");
				myAudioSRC.src=adhanAudioSource[i];
				myAudio.appendChild(myAudioSRC);
			}
			changeImg=true;
			IGS=nightImg;
			if(allowSoundPuasa.adhan){
				document.body.appendChild(myAudio);
				setTimeout(function(){myAudio.play();}, 5000);
			}
			putTheAdhanAudio=false;
		}
		if(S1){
		theInnerBar.style.width = (nowfasting/fastingTime*theOuterBar.offsetWidth)+"px";
		if(changeImg){
			if(GG<STTPS){if(S1){vthumbImg.src=KadRaya;}}
			else{
			if(S1)vthumbImg.src=IGS;}
			changeImg=false;
		}}
	}else{
		if(S3){myTimeWrite.innerHTML=DD+"<br/>"+writeIslamicDate()+"<br/>"+new Date(GG).getHours()+":"+new Date(GG).getMinutes();}
		if(night){
			if(S2){GIGI("b")}
			if(S1){fstingmsj.innerHTML = msjBerbuka;}
			if(tsdsa==TM/1000){changeImg=true;}
			IGS=nightImg;
		}
		if(midnight){
			if(S2){GIGI("b")}
			if(S1){fstingmsj.innerHTML = msjBerbuka;}
			if(tsdsa==TI/1000||parseInt(GG)==parseInt(theZeroTime)){changeImg=true;}
			IGS=midnightImg;
		}
		if(fajar){
			if(S2){GIGI("s")}
			if(S1){fstingmsj.innerHTML = msjSahur}
			if(tsdsa==TMN/1000){changeImg=true;}
			IGS=fajarImg;
		}
		if(changeImg){
			if(S1){
				if(GG<STTPS){if(S1){vthumbImg.src=KadRaya;}}
				else{
				if(S1){vthumbImg.src=IGS};}
				changeImg=false;
			}
		}
		if(GG>ENDPS-86400000){
			if(changeImg){
			if(S1){
				if(S1){vthumbImg.src=KadRaya};
				changeImg=false;
			}
			}
			if(tsdsa==parseInt(ENDPS/1000)){
				SWBP2PO(S1,S2,S3,N,E,Z,ID,10,'1px solid',5,3,5,180,16,'#f00','#0f0','#f55','#55f','#fff');
			}
			if(putTakbirAudio&&tsdsa==parseInt((TI+900000)/1000)){
				for(var i=0;i<takbirAudioSource.length;i++){
					myAudioSRC = document.createElement("source");
					myAudioSRC.src=takbirAudioSource[i];
					myAudio.appendChild(myAudioSRC);
				}
			
				if(allowSoundPuasa.takbir){
					document.body.appendChild(myAudio);
					setTimeout(function(){myAudio.play();}, 5000);
				}
				putTakbirAudio=false;
			}
		}
	}
}}}